// pages/world/world.js
// 语言包
var chi = require('../../utils/Chinese.js')
var eng = require("../../utils/English.js")
//获取应用实例
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    language: '',
    // 语言包对象
    content: '',

    bac: {
      world: '../../img/world_03.jpg',
      world1: '../../img/world_05.jpg',
      world2: '../../img/world_07.jpg',
      // world3: '../../img/world_09.jpg',
    }
  },
  // 事件函数
  world: function (e) {
    var id = e.currentTarget.id
    wx.navigateTo({
      url: '../world_detail/world_detail',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    let that = this
    console.log(app.data.language)
    this.setData({
      language: app.data.language
    })
    var lastLanuage = that.data.language
    if (lastLanuage == 'zh_CN') {
      that.setData({
        content: chi.content
      })
      // 修改tabbar
      wx.setTabBarItem({
        index: 0,
        text: '首页'
      })
      wx.setTabBarItem({
        index: 1,
        text: '购物车',
      })
      wx.setTabBarItem({
        index: 4,
        text: '我的',
      })
    } else if (lastLanuage == 'zh_EN') {
      that.setData({
        content: eng.content
      })
      // 修改tabbar
      wx.setTabBarItem({
        index: 0,
        text: 'Home'
      })
      wx.setTabBarItem({
        index: 1,
        text: 'shopping'
      })
      wx.setTabBarItem({
        index: 4,
        text: 'My',
      })

    }

    // -------------------------------


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this
    console.log(app.data.language)
    this.setData({
      language: app.data.language
    })
    var lastLanuage = that.data.language
    if (lastLanuage == 'zh_CN') {
      that.setData({
        content: chi.content
      })
      // 修改tabbar
      wx.setTabBarItem({
        index: 0,
        text: '首页'
      })
      wx.setTabBarItem({
        index: 1,
        text: '购物车',
      })
      wx.setTabBarItem({
        index: 4,
        text: '我的',
      })
    } else if (lastLanuage == 'zh_EN') {
      that.setData({
        content: eng.content
      })
      // 修改tabbar
      wx.setTabBarItem({
        index: 0,
        text: 'Home'
      })
      wx.setTabBarItem({
        index: 1,
        text: 'shopping'
      })
      wx.setTabBarItem({
        index: 4,
        text: 'My',
      })

    }

    // -------------------------------

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})